<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true"  label-width="85px">
      <el-form-item label="设备编号" prop="instrumentId">
        <el-input
          v-model="queryParams.instrumentId"
          placeholder="请输入设备编号"
          clearable="true"
          @keyup.enter.native="handleQuery"
          @change="autoCheckUpdate"
        />
      </el-form-item>


<!--      <el-form-item label="设备名称" prop="instrumentName">
        <el-input
          v-model="queryParams.instrumentName"
          placeholder="请输入设备名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="设备类型" prop="equipmentType">
        <el-select
          v-model="queryParams.equipmentType"
          placeholder="请选择设备类型"
          @change="TypeChange"
          clearable="true"
        >
          <el-option
            v-for="dict in dict.type.yh_equip_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item>

      <el-form-item label="设备名称" prop="instrumentName" >
        <el-select
          v-model="queryParams.instrumentName"
          placeholder="设备名称"
          clearable="true"
        >
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>


      <el-form-item label="型号" prop="modelNumber" v-show="showSearch">
        <el-input
          v-model="queryParams.modelNumber"
          placeholder="请输入设备型号"
          clearable="true"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格" prop="specification" v-show="showSearch">
        <el-input
          v-model="queryParams.specification"
          placeholder="请输入规格"
          clearable="true"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="领用人姓名" prop="receiverName">
        <el-input
          v-model="queryParams.receiverName"
          placeholder="请输入领用人姓名"
          clearable="true"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="存放地名称" prop="storageLocation">
        <el-input
          v-model="queryParams.storageLocation"
          placeholder="请输入存放地名称"
          clearable="true"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="领用单位" prop="applicationDepartment">
              <el-input
                v-model="queryParams.applicationDepartment"
                placeholder="请输入领用单位"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="型号" prop="modelNumber">
              <el-input
                v-model="queryParams.modelNumber"
                placeholder="请输入型号"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="规格" prop="specification">
              <el-input
                v-model="queryParams.specification"
                placeholder="请输入规格"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="单价" prop="unitPrice">
              <el-input
                v-model="queryParams.unitPrice"
                placeholder="请输入单价"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="分类号" prop="classifyNumber">
              <el-input
                v-model="queryParams.classifyNumber"
                placeholder="请输入分类号"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="购置日期" prop="purchaseDate">
              <el-date-picker clearable
                v-model="queryParams.purchaseDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择购置日期">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="领用人工号" prop="receiverId">
              <el-input
                v-model="queryParams.receiverId"
                placeholder="请输入领用人工号"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="领用人姓名" prop="receiverName">
              <el-input
                v-model="queryParams.receiverName"
                placeholder="请输入领用人姓名"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="厂家" prop="manufacturers">
              <el-input
                v-model="queryParams.manufacturers"
                placeholder="请输入厂家"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="入库日期" prop="storageDate">
              <el-date-picker clearable
                v-model="queryParams.storageDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择入库日期">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="存放地名称" prop="storageLocation">
              <el-input
                v-model="queryParams.storageLocation"
                placeholder="请输入存放地名称"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="用户ID" prop="userId">
              <el-input
                v-model="queryParams.userId"
                placeholder="请输入用户ID"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="部门ID" prop="deptId">
              <el-input
                v-model="queryParams.deptId"
                placeholder="请输入部门ID"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="创建者" prop="createBy">
              <el-input
                v-model="queryParams.createBy"
                placeholder="请输入创建者"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="创建时间" prop="createTime">
              <el-date-picker clearable
                v-model="queryParams.createTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择创建时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="更新者" prop="updateBy">
              <el-input
                v-model="queryParams.updateBy"
                placeholder="请输入更新者"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="更新时间" prop="updateTime">
              <el-date-picker clearable
                v-model="queryParams.updateTime"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="请选择更新时间">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="备注1" prop="note1">
              <el-input
                v-model="queryParams.note1"
                placeholder="请输入备注1"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="备注2" prop="note2">
              <el-input
                v-model="queryParams.note2"
                placeholder="请输入备注2"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="备注3" prop="note3">
              <el-input
                v-model="queryParams.note3"
                placeholder="请输入备注3"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="备注4" prop="note4">
              <el-input
                v-model="queryParams.note4"
                placeholder="请输入备注4"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="备注5" prop="note5">
              <el-input
                v-model="queryParams.note5"
                placeholder="请输入备注5"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="备注6" prop="note6">
              <el-input
                v-model="queryParams.note6"
                placeholder="请输入备注6"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="备注7" prop="note7">
              <el-input
                v-model="queryParams.note7"
                placeholder="请输入备注7"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="备注8" prop="note8">
              <el-input
                v-model="queryParams.note8"
                placeholder="请输入备注8"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="备注9" prop="note9">
              <el-input
                v-model="queryParams.note9"
                placeholder="请输入备注9"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>
            <el-form-item label="备注10" prop="note10">
              <el-input
                v-model="queryParams.note10"
                placeholder="请输入备注10"
                clearable
                @keyup.enter.native="handleQuery"
              />
            </el-form-item>-->

        <br/>
        <div style="text-align: right;">
        <el-button  type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>

        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['kfc:equipment:export']"
        >导出</el-button>

        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </div>
        <br/>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['kfc:equipment:add']"
        >新增</el-button>
      </el-col>
<!--            <el-col :span="1.5">
              <el-button
                type="success"
                plain
                icon="el-icon-edit"
                size="mini"
                :disabled="single"
                @click="handleUpdate"
                v-hasPermi="['project:equipment:edit']"
              >修改</el-button>
            </el-col>-->
<!--            <el-col :span="1.5">-->
<!--              <el-button-->
<!--                type="danger"-->
<!--                plain-->
<!--                icon="el-icon-delete"-->
<!--                size="mini"-->
<!--                :disabled="multiple"-->
<!--                @click=""-->
<!--                v-hasPermi="['kfc:equipment:edit']"-->
<!--              >删除</el-button>-->
<!--            </el-col>-->

      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['kfc:equipment:import']"
        >导入
        </el-button>
      </el-col>


      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="equipmentList" @selection-change="handleSelectionChange"
              border
              :row-style="{height:'35px'}"
              :cell-style="{padding:'0px'}">
<!--      <el-table-column type="selection" width="55" align="center" />-->
      <el-table-column label="序号" align="center" :index="indexMethod" type="index"  />
      <el-table-column label="设备编号" align="center" prop="instrumentId" width="120"/>
      <el-table-column label="设备类型" align="center" prop="equipmentType" width="130">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.yh_equip_type" :value="scope.row.equipmentType"/>
        </template>
      </el-table-column>
      <el-table-column label="设备名称" align="center" prop="instrumentName" />

      <el-table-column label="型号" align="center" prop="modelNumber" width="150"/>
      <el-table-column label="规格" align="center" prop="specification" width="150"/>
      <!--      <el-table-column label="设备类别" align="center" prop="equipmentType" />-->
<!--      <el-table-column label="领用单位" align="center" prop="applicationDepartment" width="150"/>-->
      <!--      <el-table-column label="型号" align="center" prop="modelNumber" />
            <el-table-column label="规格" align="center" prop="specification" />
            <el-table-column label="单价" align="center" prop="unitPrice" />
            <el-table-column label="分类号" align="center" prop="classifyNumber" />
            <el-table-column label="购置日期" align="center" prop="purchaseDate" width="180">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.purchaseDate, '{y}-{m}-{d}') }}</span>
              </template>
            </el-table-column>-->
<!--      <el-table-column label="领用人工号" align="center" prop="receiverId" />-->
      <el-table-column label="领用人姓名" align="center" prop="receiverName" width="100"/>
      <!--      <el-table-column label="厂家" align="center" prop="manufacturers" />
            <el-table-column label="入库日期" align="center" prop="storageDate" width="180">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.storageDate, '{y}-{m}-{d}') }}</span>
              </template>
            </el-table-column>-->
      <el-table-column label="存放地名称" align="center" prop="storageLocation" />
      <!--      <el-table-column label="用户ID" align="center" prop="userId" />
            <el-table-column label="部门ID" align="center" prop="deptId" />-->
      <!--      <el-table-column label="创建者" align="center" prop="createBy" />
            <el-table-column label="创建时间" align="center" prop="createTime" width="180">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
              </template>
            </el-table-column>
            <el-table-column label="更新者" align="center" prop="updateBy" />
            <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
              </template>
            </el-table-column>-->
<!--      <el-table-column label="备注" align="center" prop="remark" />-->
      <!--      <el-table-column label="备注1" align="center" prop="note1" />
            <el-table-column label="备注2" align="center" prop="note2" />
            <el-table-column label="备注3" align="center" prop="note3" />
            <el-table-column label="备注4" align="center" prop="note4" />
            <el-table-column label="备注5" align="center" prop="note5" />
            <el-table-column label="备注6" align="center" prop="note6" />
            <el-table-column label="备注7" align="center" prop="note7" />
            <el-table-column label="备注8" align="center" prop="note8" />
            <el-table-column label="备注9" align="center" prop="note9" />
            <el-table-column label="备注10" align="center" prop="note10" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width"  width="100">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['kfc:equipment:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleUpdate1(scope.row)"
            v-hasPermi="['kfc:equipment:edit']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 添加或修改设备信息对话框 -->
    <el-dialog :title="title" :visible.sync="open1" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff;font-size: 18px;">设备信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-table-row>
              <el-col span="12">
                <el-form-item label="设备编号" prop="instrumentId">
                  <el-input v-model="form.instrumentId" placeholder="请输入设备编号" disabled="disabled" />
                </el-form-item>
              </el-col>
              <el-col span="12">
                <el-form-item label="设备名称" prop="instrumentName">
                  <el-input v-model="form.instrumentName" placeholder="请输入设备名称" />
                </el-form-item>
              </el-col>
              <el-col span="12">
                <el-form-item label="设备类别" prop="equipmentType">
                  <el-select v-model="form.equipmentType" placeholder="请选择设备类别" style="width: 100%">
                    <el-option
                      v-for="dict in dict.type.yh_equip_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
<!--                  <el-input v-model="form.equipmentType" placeholder="请输入设备类别" />-->
                </el-form-item>
              </el-col>
              <el-col span="12">
                <el-form-item label="设备型号" prop="modelNumber">
                  <el-input v-model="form.modelNumber" placeholder="请输入设备型号" />
                </el-form-item>
              </el-col>
              <el-col span="12">
                <el-form-item label="设备规格" prop="specification">
                  <el-input v-model="form.specification" placeholder="请输入设备规格" />
                </el-form-item>
              </el-col>

              <el-col span="12">
                <el-form-item label="设备价格" prop="unitPrice">
                  <el-input v-model="form.unitPrice" placeholder="请输入设备价格" />
                </el-form-item>
              </el-col>

              <el-col span="12" >
            <el-form-item label="购置日期" prop="purchaseDate" >
              <el-date-picker clearable
                              v-model="form.purchaseDate"
                              type="date"
                              style="width:100%"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择购置日期">
              </el-date-picker>
            </el-form-item>
              </el-col>

            <el-col span="12">
              <el-form-item label="分类号" prop="classifyNumber">
                <el-input v-model="form.classifyNumber" placeholder="请输入分类号" />
              </el-form-item>
            </el-col>

              <el-col span="12">
            <el-form-item label="入库日期" prop="storageDate">
              <el-date-picker clearable
                              v-model="form.storageDate"
                              type="date"
                              style="width:100%"
                              value-format="yyyy-MM-dd"
                              placeholder="请选择入库日期">
              </el-date-picker>
            </el-form-item>
              </el-col>


            <el-col span="12">
              <el-form-item label="厂家信息" prop="manufacturers">
                <el-input v-model="form.manufacturers" placeholder="请输入厂家信息" />
              </el-form-item>
            </el-col>

            <el-table-row>
              <el-col span="12">
                <el-form-item label="领用单位" prop="applicationDepartment">
                  <el-input v-model="form.applicationDepartment" placeholder="请输入领用单位" />
                </el-form-item>
              </el-col>

              <el-col span="12">
                <el-form-item label="领用人工号" prop="receiverId">
                  <el-input v-model="form.receiverId" placeholder="请输入领用人工号" />
                </el-form-item>
              </el-col>
            </el-table-row>

            <el-table-row>
              <el-col span="12">
                <el-form-item label="领用人姓名" prop="receiverName">
                  <el-input v-model="form.receiverName" placeholder="请输入领用人姓名" />
                </el-form-item>
              </el-col>


              <el-col span="12">
                <el-form-item label="存放地名称" prop="storageLocation">
                  <el-input v-model="form.storageLocation" placeholder="请输入存放地名称" />
                </el-form-item>
              </el-col>
            </el-table-row>

            <el-table-row>
              <el-col span="24">
                <el-form-item label="备注信息" prop="remark">
                  <el-input :rows="1" v-model="form.remark" type="textarea" placeholder="请输入内容" />
                </el-form-item>
              </el-col>
            </el-table-row>

            </el-table-row>
          </el-main>
          <!--          <el-header>
                      <el-divider content-position="left">
                        <p style="color: #00afff;font-size: 18px;">附件信息</p>
                      </el-divider>
                    </el-header>
                    <el-main>
                      <el-table-row>
                        <el-col span="24">
                          <el-form-item label="电子附件" prop="enclosure">
                            <file-upload   v-model="form.enclosure"/>
                          </el-form-item>
                        </el-col>
                      </el-table-row>
                    </el-main>-->
        </el-container>



        <!--    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
              <el-form ref="form" :model="form" :rules="rules" label-width="80px">
                <el-form-item label="设备编号" prop="instrumentId">
                  <el-input v-model="form.instrumentId" placeholder="请输入设备编号" />
                </el-form-item>
                <el-form-item label="设备名称" prop="instrumentName">
                  <el-input v-model="form.instrumentName" placeholder="请输入设备名称" />
                </el-form-item>
                <el-form-item label="领用单位" prop="applicationDepartment">
                  <el-input v-model="form.applicationDepartment" placeholder="请输入领用单位" />
                </el-form-item>
                <el-form-item label="型号" prop="modelNumber">
                  <el-input v-model="form.modelNumber" placeholder="请输入型号" />
                </el-form-item>
                <el-form-item label="规格" prop="specification">
                  <el-input v-model="form.specification" placeholder="请输入规格" />
                </el-form-item>
                <el-form-item label="单价" prop="unitPrice">
                  <el-input v-model="form.unitPrice" placeholder="请输入单价" />
                </el-form-item>
                <el-form-item label="分类号" prop="classifyNumber">
                  <el-input v-model="form.classifyNumber" placeholder="请输入分类号" />
                </el-form-item>
                <el-form-item label="购置日期" prop="purchaseDate">
                  <el-date-picker clearable
                    v-model="form.purchaseDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择购置日期">
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="领用人工号" prop="receiverId">
                  <el-input v-model="form.receiverId" placeholder="请输入领用人工号" />
                </el-form-item>
                <el-form-item label="领用人姓名" prop="receiverName">
                  <el-input v-model="form.receiverName" placeholder="请输入领用人姓名" />
                </el-form-item>
                <el-form-item label="厂家" prop="manufacturers">
                  <el-input v-model="form.manufacturers" placeholder="请输入厂家" />
                </el-form-item>
                <el-form-item label="入库日期" prop="storageDate">
                  <el-date-picker clearable
                    v-model="form.storageDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择入库日期">
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="存放地名称" prop="storageLocation">
                  <el-input v-model="form.storageLocation" placeholder="请输入存放地名称" />
                </el-form-item>
                <el-form-item label="用户ID" prop="userId">
                  <el-input v-model="form.userId" placeholder="请输入用户ID" />
                </el-form-item>
                <el-form-item label="部门ID" prop="deptId">
                  <el-input v-model="form.deptId" placeholder="请输入部门ID" />
                </el-form-item>
                <el-form-item label="备注" prop="remark">
                  <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
                </el-form-item>
                <el-form-item label="备注1" prop="note1">
                  <el-input v-model="form.note1" placeholder="请输入备注1" />
                </el-form-item>
                <el-form-item label="备注2" prop="note2">
                  <el-input v-model="form.note2" placeholder="请输入备注2" />
                </el-form-item>
                <el-form-item label="备注3" prop="note3">
                  <el-input v-model="form.note3" placeholder="请输入备注3" />
                </el-form-item>
                <el-form-item label="备注4" prop="note4">
                  <el-input v-model="form.note4" placeholder="请输入备注4" />
                </el-form-item>
                <el-form-item label="备注5" prop="note5">
                  <el-input v-model="form.note5" placeholder="请输入备注5" />
                </el-form-item>
                <el-form-item label="备注6" prop="note6">
                  <el-input v-model="form.note6" placeholder="请输入备注6" />
                </el-form-item>
                <el-form-item label="备注7" prop="note7">
                  <el-input v-model="form.note7" placeholder="请输入备注7" />
                </el-form-item>
                <el-form-item label="备注8" prop="note8">
                  <el-input v-model="form.note8" placeholder="请输入备注8" />
                </el-form-item>
                <el-form-item label="备注9" prop="note9">
                  <el-input v-model="form.note9" placeholder="请输入备注9" />
                </el-form-item>
                <el-form-item label="备注10" prop="note10">
                  <el-input v-model="form.note10" placeholder="请输入备注10" />
                </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel1">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改设备信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
        <el-container>
          <el-header>
            <el-divider content-position="left">
              <p style="color: #00afff;font-size: 18px;">设备信息</p>
            </el-divider>
          </el-header>
          <el-main>
            <el-table-row>
              <el-col span="12">
                <el-form-item label="设备编号" prop="instrumentId">
                  <el-input v-model="form.instrumentId" placeholder="请输入设备编号" />
                </el-form-item>
              </el-col>
              <el-col span="12">
                <el-form-item label="设备名称" prop="instrumentName">
                  <el-input v-model="form.instrumentName" placeholder="请输入设备名称" />
                </el-form-item>
              </el-col>
              <el-col span="12">
                <el-form-item label="设备类别" prop="equipmentType">
                  <el-select v-model="form.equipmentType" placeholder="请选择设备类别" style="width: 100%">
                    <el-option
                      v-for="dict in dict.type.yh_equip_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    ></el-option>
                  </el-select>
                  <!--                  <el-input v-model="form.equipmentType" placeholder="请输入设备类别" />-->
                </el-form-item>
              </el-col>
              <el-col span="12">
                <el-form-item label="设备型号" prop="modelNumber">
                  <el-input v-model="form.modelNumber" placeholder="请输入设备型号" />
                </el-form-item>
              </el-col>
              <el-col span="12">
                <el-form-item label="设备规格" prop="specification">
                  <el-input v-model="form.specification" placeholder="请输入设备规格" />
                </el-form-item>
              </el-col>

              <el-col span="12">
                <el-form-item label="设备价格" prop="unitPrice">
                  <el-input v-model="form.unitPrice" placeholder="请输入设备价格" />
                </el-form-item>
              </el-col>

              <el-col span="12" >
                <el-form-item label="购置日期" prop="purchaseDate" >
                  <el-date-picker clearable
                                  v-model="form.purchaseDate"
                                  type="date"
                                  style="width:100%"
                                  value-format="yyyy-MM-dd"
                                  placeholder="请选择购置日期">
                  </el-date-picker>
                </el-form-item>
              </el-col>

              <el-col span="12">
                <el-form-item label="分类号" prop="classifyNumber">
                  <el-input v-model="form.classifyNumber" placeholder="请输入分类号" />
                </el-form-item>
              </el-col>

              <el-col span="12">
                <el-form-item label="入库日期" prop="storageDate">
                  <el-date-picker clearable
                                  v-model="form.storageDate"
                                  type="date"
                                  style="width:100%"
                                  value-format="yyyy-MM-dd"
                                  placeholder="请选择入库日期">
                  </el-date-picker>
                </el-form-item>
              </el-col>


              <el-col span="12">
                <el-form-item label="厂家信息" prop="manufacturers">
                  <el-input v-model="form.manufacturers" placeholder="请输入厂家信息" />
                </el-form-item>
              </el-col>

              <el-table-row>
                <el-col span="12">
                  <el-form-item label="领用单位" prop="applicationDepartment">
                    <el-input v-model="form.applicationDepartment" placeholder="请输入领用单位" />
                  </el-form-item>
                </el-col>

                <el-col span="12">
                  <el-form-item label="领用人工号" prop="receiverId">
                    <el-input v-model="form.receiverId" placeholder="请输入领用人工号" />
                  </el-form-item>
                </el-col>
              </el-table-row>

              <el-table-row>
                <el-col span="12">
                  <el-form-item label="领用人姓名" prop="receiverName">
                    <el-input v-model="form.receiverName" placeholder="请输入领用人姓名" />
                  </el-form-item>
                </el-col>


                <el-col span="12">
                  <el-form-item label="存放地名称" prop="storageLocation">
                    <el-input v-model="form.storageLocation" placeholder="请输入存放地名称" />
                  </el-form-item>
                </el-col>
              </el-table-row>

              <el-table-row>
                <el-col span="24">
                  <el-form-item label="备注信息" prop="remark">
                    <el-input :rows="1" v-model="form.remark" type="textarea" placeholder="请输入内容" />
                  </el-form-item>
                </el-col>
              </el-table-row>

            </el-table-row>
          </el-main>
          <!--          <el-header>
                      <el-divider content-position="left">
                        <p style="color: #00afff;font-size: 18px;">附件信息</p>
                      </el-divider>
                    </el-header>
                    <el-main>
                      <el-table-row>
                        <el-col span="24">
                          <el-form-item label="电子附件" prop="enclosure">
                            <file-upload   v-model="form.enclosure"/>
                          </el-form-item>
                        </el-col>
                      </el-table-row>
                    </el-main>-->
        </el-container>



        <!--    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
              <el-form ref="form" :model="form" :rules="rules" label-width="80px">
                <el-form-item label="设备编号" prop="instrumentId">
                  <el-input v-model="form.instrumentId" placeholder="请输入设备编号" />
                </el-form-item>
                <el-form-item label="设备名称" prop="instrumentName">
                  <el-input v-model="form.instrumentName" placeholder="请输入设备名称" />
                </el-form-item>
                <el-form-item label="领用单位" prop="applicationDepartment">
                  <el-input v-model="form.applicationDepartment" placeholder="请输入领用单位" />
                </el-form-item>
                <el-form-item label="型号" prop="modelNumber">
                  <el-input v-model="form.modelNumber" placeholder="请输入型号" />
                </el-form-item>
                <el-form-item label="规格" prop="specification">
                  <el-input v-model="form.specification" placeholder="请输入规格" />
                </el-form-item>
                <el-form-item label="单价" prop="unitPrice">
                  <el-input v-model="form.unitPrice" placeholder="请输入单价" />
                </el-form-item>
                <el-form-item label="分类号" prop="classifyNumber">
                  <el-input v-model="form.classifyNumber" placeholder="请输入分类号" />
                </el-form-item>
                <el-form-item label="购置日期" prop="purchaseDate">
                  <el-date-picker clearable
                    v-model="form.purchaseDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择购置日期">
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="领用人工号" prop="receiverId">
                  <el-input v-model="form.receiverId" placeholder="请输入领用人工号" />
                </el-form-item>
                <el-form-item label="领用人姓名" prop="receiverName">
                  <el-input v-model="form.receiverName" placeholder="请输入领用人姓名" />
                </el-form-item>
                <el-form-item label="厂家" prop="manufacturers">
                  <el-input v-model="form.manufacturers" placeholder="请输入厂家" />
                </el-form-item>
                <el-form-item label="入库日期" prop="storageDate">
                  <el-date-picker clearable
                    v-model="form.storageDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="请选择入库日期">
                  </el-date-picker>
                </el-form-item>
                <el-form-item label="存放地名称" prop="storageLocation">
                  <el-input v-model="form.storageLocation" placeholder="请输入存放地名称" />
                </el-form-item>
                <el-form-item label="用户ID" prop="userId">
                  <el-input v-model="form.userId" placeholder="请输入用户ID" />
                </el-form-item>
                <el-form-item label="部门ID" prop="deptId">
                  <el-input v-model="form.deptId" placeholder="请输入部门ID" />
                </el-form-item>
                <el-form-item label="备注" prop="remark">
                  <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
                </el-form-item>
                <el-form-item label="备注1" prop="note1">
                  <el-input v-model="form.note1" placeholder="请输入备注1" />
                </el-form-item>
                <el-form-item label="备注2" prop="note2">
                  <el-input v-model="form.note2" placeholder="请输入备注2" />
                </el-form-item>
                <el-form-item label="备注3" prop="note3">
                  <el-input v-model="form.note3" placeholder="请输入备注3" />
                </el-form-item>
                <el-form-item label="备注4" prop="note4">
                  <el-input v-model="form.note4" placeholder="请输入备注4" />
                </el-form-item>
                <el-form-item label="备注5" prop="note5">
                  <el-input v-model="form.note5" placeholder="请输入备注5" />
                </el-form-item>
                <el-form-item label="备注6" prop="note6">
                  <el-input v-model="form.note6" placeholder="请输入备注6" />
                </el-form-item>
                <el-form-item label="备注7" prop="note7">
                  <el-input v-model="form.note7" placeholder="请输入备注7" />
                </el-form-item>
                <el-form-item label="备注8" prop="note8">
                  <el-input v-model="form.note8" placeholder="请输入备注8" />
                </el-form-item>
                <el-form-item label="备注9" prop="note9">
                  <el-input v-model="form.note9" placeholder="请输入备注9" />
                </el-form-item>
                <el-form-item label="备注10" prop="note10">
                  <el-input v-model="form.note10" placeholder="请输入备注10" />
                </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px">
      <el-upload
        ref="upload"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">
          将文件拖到此处，或
          <em>点击上传</em>
        </div>
        <div class="el-upload__tip" slot="tip">
          <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的设备数据
          <el-link type="info" style="font-size:12px;color:blue" @click="importTemplate" >下载模板</el-link>
        </div>
        <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>


  </div>
</template>

<script>
import { listEquipment, getEquipment, delEquipment, addEquipment, updateEquipment,typeEquipment} from "@/api/module/kfc/equipment";
import { getToken } from "@/utils/auth";
import { importTemplate } from "@/api/system/user";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import {delBaseinfo} from "@/api/module/ljw/baseinfo";

export default {
  name: "Equipment",
  dicts:['yh_equip_type'],
  data() {
    return {
      options:[],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: false,
      // 总条数
      total: 0,
      // 设备信息表格数据
      equipmentList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      open1:false,
      open2:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        instrumentId: null,
        instrumentName: null,
        equipmentType: null,
        applicationDepartment: null,
        modelNumber: null,
        specification: null,
        unitPrice: null,
        classifyNumber: null,
        purchaseDate: null,
        receiverId: null,
        receiverName: null,
        manufacturers: null,
        storageDate: null,
        storageLocation: null,
        userId: null,
        deptId: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        instrumentId: [
          { required: true, message: "设备编号不能为空", trigger: "blur" },
        ],
        instrumentName: [
          { required: true, message: "设备名称不能为空", trigger: "blur" },
        ],
        equipmentType: [
          { required: true, message: "设备类别不能为空", trigger: "blur" },
        ],
        applicationDepartment: [
          { required: true, message: "领用单位不能为空", trigger: "blur" },
        ],
        receiverId: [
          { required: true, message: "领用人工号不能为空", trigger: "blur" },
        ],
        receiverName: [
          { required: true, message: "领用人姓名不能为空", trigger: "blur" },
        ],
        storageLocation: [
          { required: true, message: "存放地名称不能为空", trigger: "blur" },
        ],
      },



      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {Authorization: "Bearer " + getToken()},
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/project/kfc/equipment/importData",
        fileList: []
      },
      searchData: {
        inputValue1: '',
        inputValue2: '',
        date: ''
      }

    };
  },
  created() {
    const  equipment = this.$route.query. equipment;
    const firstname = this.$route.query.firstname;
    const  equipmentlocal = this.$route.query. equipmentlocal;


    const barcode = this.$route.query.barcode;
    console.log( equipment+" equipment");
    console.log(barcode+"barcode");
    if ( equipment) {
      // 获取表详细信息
      this.queryParams.dataname= equipment;
      this.queryParams.barcode=barcode;
      listEquipment(this.queryParams).then(response => {
        this.equipmentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    }else if(firstname){
      // 获取表详细信息
      this.queryParams.firstpeople=firstname;
      this.queryParams.barcode=barcode;
      listEquipment(this.queryParams).then(response => {
        this. equipmentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    }else if( equipmentlocal){
      // 获取表详细信息
      this.queryParams.position= equipmentlocal;
      this.queryParams.barcode=barcode;
      listEquipment(this.queryParams).then(response => {
        this.equipmentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    }else if(barcode){
      // 获取表详细信息

      this.queryParams.barcode=barcode;
      listEquipment(this.queryParams).then(response => {
        this.equipmentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    }
    else {
      this.getList();
    }
  },
  methods: {

    TypeChange(e){
      if(e){
        this.options=[],
          delete this.queryParams.instrumentName;    //删除第二个select绑定的属性
        typeEquipment(e).then(response => {
          this.data = response.data;
          for (let i = 0; i < this.data.length; i++) {
            this.options.push({
              value: this.data[i].instrumentName,
              label: this.data[i].instrumentName,
            })
          }
        });
      }
      else{
        this.options=[]
      }
    },
    getFilterData() {
      this.$emit('getFilterData', this.searchData)
    },
    getNowTime() {
      var now = new Date()
      var year = now.getFullYear() // 得到年份
      var month = now.getMonth() // 得到月份
      var date = now.getDate() // 得到日期
      month = month + 1
      month = month.toString().padStart(2, '0')
      date = date.toString().padStart(2, '0')
      var defaultDate = `${year}-${month}-${date}`
      this.$set(this.searchData, 'date', defaultDate)
    },

    //生成表头序号
    indexMethod(index) {
      index = (index + 1) + (this.queryParams.pageNum - 1) * this.queryParams.pageSize
      return index;
    },


    /** 查询设备信息列表 */
    getList() {
      this.loading = true;
      listEquipment(this.queryParams).then(response => {
        this.equipmentList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    cancel1(){
      this.open1 = false;
      this.reset();
    },
    cancel2(){
      this.open2 = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        instrumentId: null,
        instrumentName: null,
        equipmentType: null,
        applicationDepartment: null,
        modelNumber: null,
        specification: null,
        unitPrice: null,
        classifyNumber: null,
        purchaseDate: null,
        receiverId: null,
        receiverName: null,
        manufacturers: null,
        storageDate: null,
        storageLocation: null,
        userId: null,
        deptId: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        note1: null,
        note2: null,
        note3: null,
        note4: null,
        note5: null,
        note6: null,
        note7: null,
        note8: null,
        note9: null,
        note10: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加设备信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getEquipment(id).then(response => {
        this.form = response.data;
        this.open1 = true;
        this.title = "修改设备信息";
      });
    },
    /** 删除按钮操作 */
    handleUpdate1(row) {
      this.reset();
      const id = row.id || this.ids
      this.$modal.confirm('是否确认删除设备信息？').then(function() {
        /*return delBaseinfo(IDs);*/
      }).then(() => {
        getEquipment(id).then(response => {
          this.form = response.data;
          this.form.note3="1";
          updateEquipment(this.form).then(response => {
            this.$modal.msgSuccess("删除成功");
            this.open = false;
            this.getList();
          });
          /*this.open = true;*/
          /*this.title = "修改设备信息";*/
        });
      }).catch(() => {});
    },

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
            if (this.form.id != null) {
              updateEquipment(this.form).then(response => {
                this.$modal.msgSuccess("修改成功");
                this.open1 = false;
                this.getList();
              });
            } else {
              addEquipment(this.form).then(response => {
                this.$modal.msgSuccess("新增成功");
                this.open= false;
                this.getList();
              });
            }
          }
      });
    },

    // 文件提交处理
    submitUpload() {
      this.$refs.upload.submit();
    },

    /*    /!** 详情操作 *!/
        handlelook(row) {
          const id = row.id;
          // const tableName = row.tableName || this.tableNames[0];
          const params = {pageNum: this.queryParams.pageNum};

          this.$router.push({path: "/basedata/appointment_detail", query: {id}});
        },*/

    /** 下载模板操作 */
    importTemplate() {
      this.download('/project/kfc/equipment/importTemplate', {}, `equipment_template_${new Date().getTime()}.xlsx`)
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "导入";
      this.upload.open = true;
    },
// 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
// 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", {dangerouslyUseHTMLString: true});
      this.getList();
    },
// 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },



    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除设备信息编号为"' + ids + '"的数据项？').then(function() {
        return delEquipment(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('/project/kfc/equipment/export', {
        ...this.queryParams
      }, `equipment_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>

<style>
/*.btn{
  margin-left: 960px;
}*/
/*.el-divider {
  background-color: unset;
  height: 36px;
  margin: 10px 0;
}
.el-divider__text.is-left {
  color: #409eff;
  background: none;
  top: 10px;
  left: 0;
  font-weight: bold;
}*/
/*.el-dialog {
  margin: 5vh auto !important;
}

.el-dialog__body {
  height: 18vh;
  overflow: hidden;
  overflow-y: auto;
}*/
</style>
